//轮播
$(".a_show").css("width", $(".a_wrap").width() * $(".a_show img").length);
$(".a_show img").css("width", $(".a_show").width() / $(".a_show img").length);
$(".a_wrap").css("height", $(".a_show img").height());
var index = 0;
//轮播函数
var changeImg = function() {
	$(".a_point").css({
		backgroundColor: "rgba(255,255,255,0.5)",
		border: "0.1rem solid #FFFFFF"
	});
	index++;
	$(".a_point").eq(index).css({
		backgroundColor: "#FE786F",
		border: "none"
	});
	$(".a_show").animate({
		left: -$(".a_wrap").width() * index + "px"

	}, 1000)
	if(index >= 3) {
		index = 0;
		$(".a_show").animate({
			left: 0 + "px"
		}, 0)
		$(".a_point").eq(index).css({
			backgroundColor: "#FE786F",
			border: "none"
		});
	}
}
var wheel = setInterval(changeImg, 2000);

//创建横向图标的函数
var iconArr = ["img1/img1.png",
	"img1/img2.png",
	"img1/img3.png",
	"img1/img4.png",
	"img1/img5.png",
	"img1/img6.png"
];
var iconTitle = ["王者荣誉", "天天酷跑", "全民突击", "热邪传奇", "德玛西亚", "艾欧尼亚"];
$(".b_game").width($(".b_gameList").width() * iconArr.length)
for(var i = 0; i < iconArr.length; i++) {
	var icon = createIcon(iconArr[i], iconTitle[i]);
	$(".b_game").append(icon);
}

function createIcon(imageSrc, title) {
	return $("<li class='b_gameList'><img src=" + imageSrc + " class='b_gameImg' /><span class='b_font2'>" + title + "</span><span class='b_font3'>有<em>1</em>款礼包</span></li>")
};

//主要游戏部分
//头像数组
var heardImg = [
	"img1/h_img1.png",
	"img1/h_img2.png",
	"img1/h_img3.png"
];
//主要游戏大图数组
var mainImg = [
	"img1/con1.png",
	"img1/con2.png",
	"img1/con3.png"
];
//小图数组
var smallImg = [
	["img1/s_img1.png", "img1/s_img2.png"],
	["img1/s_img3.png"],
	["img1/s_img5.png", "img1/s_img6.png"]
];
//创建主要游戏循环
for(var i = 0; i < mainImg.length; i++) {
	var wrap = $("<div class='b_con1'></div>");
	var main = createmainGame(heardImg[i], mainImg[i]);
	wrap.append(main);
	$(".b_mainGame").append(wrap);
	for(var j = 0; j < smallImg[i].length; j++) {
		var list = createGameList(smallImg[i][j]);
		$(".b_smallGame").eq(i).append(list);
	};

};
//创建主要游戏
function createmainGame(h_img, c_img) {
	return $("<div class='b_icon'><img src=" + h_img + " class='b_iconImg' /><strong class='b_font1'>穿越火线</strong></div><div class='b_conWrap'><img src=" + c_img + " class='b_Img' /><span class='b_intro overhidden'>6.1版本单排上分最强打野英雄</span></div><ul class='b_info b_smallGame'></ul><div class='b_btnWrap'><button class='b_btn'>查看更多</button></div>")
};
//创建游戏列表
function createGameList(imgSrc) {
	return $("<li class='b_infoList'><img src=" + imgSrc + " class='b_infoImg' /><span class='b_font2 overhidden'>《英雄联盟》春节猴哥皮肤礼包</span></li>")
}

//循环追加视频秀区域
//视频秀区域的图片路径数组
var videoImg = [
	"img1/video1.png",
	"img1/video2.png",
	"img1/video3.png",
	"img1/video4.png",
	"img1/video1.png",
	"img1/video2.png",
	"img1/video3.png"
];
//for循环追加
for(var i = 0; i < videoImg.length; i++) {
	var list;
	var ele = createGift(videoImg[i]);
	if(i % 2 == 0) {
		list = $("<li class='b_videoList'></li>");
	};
	list.append(ele);
	$(".b_videoWrap").append(list);
}
//创建视频秀区域元素函数
function createGift(imageSrc) {
	return $("<div class='b_video'><div class='b_videoImgWrap'><img src=" + imageSrc + " class='b_videoImg' /><span class='b_videoIntro overhidden'>英雄联盟</span><span class='glyphicon glyphicon-play b_videoPlay'></span></div><div class='b_videoWordsWrap'><p class='b_videoWords'>6.1版本单排上分最强打野英雄Tops5排行</p></div></div>")
};

//向左滑动界面
var regWidth = $("#b_reg").width();
$("#b_reg").css("left", -regWidth);
touch.on($("body"), "swiperight swipeleft", function(e) {
	e.preventDefault();
	switch(e.type) {
		case "swiperight":
			$("#b_reg").animate({
				left: 0
			}, 600);
			break;
		case "swipeleft":
			$("#b_reg").animate({
				left: -regWidth + "px"
			}, 600);
			break;
		default:
			break;
	}

});